<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<title>response</title>
	<style>
		h1 {
			margin: auto;
			text-align: center;
		}

		p {
			text-align: center;
		}

		button {
			width: 100px;
			height: 30px;
			margin: 0 2px;
			color: #fff;
			border-radius: 6px;
			border: 1px solid #ccc;
			cursor: pointer;
			transition: all 0.5s;
			background-color: #CC3333;
		}

		button:hover {
			opacity: 0.6;
		}
	</style>
</head>

<body>
	<main>
		<h1 id="h1"></h1>
		<p id="p"></p>
		<p><button id="btn">立即跳转</button></p>
	</main>


	<script type="text/javascript">
		h1.innerHTML = sessionStorage.state;
		var re = h1.innerHTML.substr(-2, 2);
		h1.style.color = re == "成功" ? "green" : "red";
		var str = "";
		if (sessionStorage.html == "regsiter.html") {
			str = "注册界面";
		} else if (sessionStorage.html == "../index.html") {
			str = "首页";
		} else if (sessionStorage.html == "login.html") {
			str = "登录界面";
		} else if (sessionStorage.html == "personal.html") {
			str = "个人中心";
		} else if (sessionStorage.html == "insert.html") {
			str = "新增书籍界面";
		} else if (sessionStorage.html == "recharge.html") {
			str = "充值页面";
		}
		p.innerHTML = "3秒后自动跳转到" + str;

		setInterval(() => {
			var s = parseInt(p.innerHTML);
			s--;
			if (s == 0) {
				location = sessionStorage.html;
			}
			p.innerHTML = s + "秒后自动跳转到" + str;
		}, 1000)
		btn.onclick=e=>location = sessionStorage.html;


		document.onkeydown = keyDown;
		function keyDown(event) {
            var event = event || window.event; // 初始化事件对象
            var s = event.keyCode;
                if (s =13) {    
					location = sessionStorage.html;
                } 
        }
	</script>
</body>

</html>